﻿using Wolfpack.Periscope.Core.Interfaces;
using Wolfpack.Periscope.Core.Interfaces.Entities;
using Wolfpack.Periscope.Core.Interfaces.Events;

namespace Wolfpack.Periscope.Core
{    
    public partial class Dashboard
    {
        private void HandleWidgetResizeRequestEvent(WidgetResizeCommand args)
        {
            IDashboardPanel panelUpdated;

            ApplyLayoutToConfig(args.Content, out panelUpdated);

            _infrastructure.MessageBus.PublishAsync(new WidgetResizedEvent(this, 
                new WidgetReference
                {
                    PanelId = args.Content.PanelId,
                    PanelInstanceId = args.Content.PanelInstanceId,
                    PanelVersion = args.Content.PanelVersion,
                    WidgetId = args.Content.WidgetId
                }));
        }
    }
}